//
//  UIView-ext.swift
//  UlTableView-Programmatic
//
//  Created by jack on 2025/10/27.
//

import UIKit

extension UIView {
    func pin(to superView: UIView) {
        // 禁用 autoresizingMask 自动转换为约束（避免与手动添加的约束冲突）
        translatesAutoresizingMaskIntoConstraints = false
        
        // 添加顶部约束：当前视图顶部与父视图顶部对齐
        topAnchor.constraint(equalTo: superView.topAnchor).isActive = true
        // 添加左侧约束：当前视图左侧与父视图左侧对齐
        leadingAnchor.constraint(equalTo: superView.leadingAnchor).isActive = true
        // 添加右侧约束：当前视图右侧与父视图右侧对齐
        trailingAnchor.constraint(equalTo: superView.trailingAnchor).isActive = true
        // 添加底部约束：当前视图底部与父视图底部对齐
        bottomAnchor.constraint(equalTo: superView.bottomAnchor).isActive = true
    }
}
